package atom.core2.j2ee.tag;

import java.io.IOException;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.tagext.SimpleTagSupport;

/**
 * @author aps-zmc
 *
 */
public class ValuePairTag extends SimpleTagSupport {
	private static final long serialVersionUID = 1L;
	private String code;
	private String vpmap;
	

	public void doTag() throws JspException, IOException {
		String contextPath = ((HttpServletRequest) ((PageContext) this.getJspContext()).getRequest()).getContextPath();
		String deferContent = "";

		HttpServletRequest request = (HttpServletRequest) ((PageContext) this.getJspContext()).getRequest();
		Map dataMap = (Map) request.getAttribute(vpmap);
		deferContent=code;
		if (dataMap!=null) 
		{
			String value = (String)dataMap.get(code);
			if (value!=null)
				deferContent = value;
		}

			

		
		this.getJspContext().getOut().write(deferContent);
	}


	public String getCode()
	{
		return code;
	}


	public void setCode(String code)
	{
		this.code = code;
	}


	public String getVpmap()
    {
    	return vpmap;
    }


	public void setVpmap(String vpmap)
    {
    	this.vpmap = vpmap;
    }



}
